import os
import logging

def get_looger(filename, name=__name__):
    log_path = 'static/logs'
    if not os.path.exists(log_path):
        os.makedirs(log_path)

    logger = logging.getLogger(name)
    logger.setLevel(logging.DEBUG)

    stream_handler = logging.StreamHandler()
    stream_handler.setLevel(logging.DEBUG)
    stream_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
    logger.addHandler(stream_handler)

    file_handler = logging.FileHandler(f'static/logs/{filename}', mode='w', encoding="utf8")
    file_handler.setLevel(logging.DEBUG)
    file_handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
    logger.addHandler(file_handler)

    return logger
